package com.bbm.controller;


import com.bbm.entity.User;
import com.bbm.entity.vo.ResponseResult;
import com.bbm.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 用户表(User)表控制层
 *
 * @author lionkliu
 * @since 2024-02-18 18:04:32
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("/page")
    public ResponseResult selectPage(@RequestParam("pageNum") Integer pageNum,
                                     @RequestParam("pageSize") Integer pageSize) {
        return userService.selectPage(pageNum,pageSize);
    }

    @GetMapping("{id}")
    public ResponseResult selectOne(@PathVariable Integer id) {
        return userService.selectOne(id);
    }

    @PostMapping
    public ResponseResult insert(@RequestBody User user) {
        return userService.insertOne(user);
    }

    @PutMapping
    public ResponseResult update(@RequestBody User user) {
        return userService.updateOne(user);
    }

    @DeleteMapping("/{id}")
    public ResponseResult delete(@PathVariable Integer id) {
        return userService.deleteById(id);
    }

}
